<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 导入layui相关的样式 -->
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <!-- 导入自定义表单样式 -->
    <link rel="stylesheet" href="/css/custom.css">
    <!-- 导入layui函数库 -->
    <script src="/layui/layui.js" charset="UTF-8"></script>
    <!-- 导入jQuery函数库 -->
    <script src="/layui/jquery-2.2.1.js"></script>
</head>
<body>
<table border="1" width="1000px" height="700px" style="text-align:center">
    <tr>
        <th colspan="7" height="40px" style="background: #5FB878"><font color="#f0f8ff" size="5px">课程表</font></th>
    </tr>
    <tr>
        <th>上课日期</th>
        <th>星期</th>
        <th>上课时间</th>
        <th>授课老师</th>
        <th>上课班级</th>
        <th>上课地点</th>
        <th>课程名</th>
    </tr>
</table>


<script>
    $(function () {
        $.ajax({
            type: "get",
            url: "/syllabuss/restful_syllabus",
            success: function (datas) {
                //获取根节点
                let tbody = document.querySelector("tbody");
                // 所有数据都是放在 tbody 中的 tr 里面
                for (let i = 0; i < datas.length; i++) {
                    let num = 0;
                    let newNode_tr = document.createElement("tr");
                    //填充表格数据
                    for (let key in datas[i]) {
                        let newNode_td = document.createElement("td");
                        if (num == 0) {
                            //给每一行的第一个td 附上属性class
                            newNode_td.setAttribute("class", "kk");
                            num = 1;
                        }
                        newNode_td.innerText = datas[i][key];//添加文本
                        newNode_tr.appendChild(newNode_td);//将td放入tr中
                    }
                    tbody.appendChild(newNode_tr);
                }
            }
        });





    });





</script>
</body>
</html>